package com.zing.controller.user;

import com.zing.constant.OtherConstant;
import com.zing.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

@RestController("userShopController")
@Api(tags="店铺相关操作")
@RequestMapping("/user/shop")
@Slf4j
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/status")
    @ApiOperation("获取店铺营业状态")
    public Result<Integer> getStatus(){
        Integer status = (Integer) redisTemplate.opsForValue().get(OtherConstant.SHOP_STATUS);
        if(status == null) status = 0;
        log.info("获取店铺状态:{}", Objects.equals(status, 1) ? "营业中" : "已打样");
        return Result.success(status);
    }
}
